<?php
function spamcheck($field)
{
	//filter_var() sanitizes the e-mail
	//address using FILTER_SANITIZE_EMAIL
	$field=filter_var($field, FILTER_SANITIZE_EMAIL);

	//filter_var() validates the e-mail
	//address using FILTER_VALIDATE_EMAIL
	if(filter_var($field, FILTER_VALIDATE_EMAIL))
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

function sendMail($from,$to,$subject,$message){
	$mailcheck = spamcheck($from);
	if ($mailcheck==FALSE)
	{
		echo "Invalid input";
	}
	else
	{//send email
		mail("$to", "Subject: $subject",
		$message, "From: $from" );
		echo "Thank you for using our mail form";
	}
}

sendMail("lmlnl19@yahoo.com", 'senan_lotus@yahoo.com', 'oh la la!', 'co gi ko ta');

?>